/*
 * Exception.h
 *
 *  Created on: 2011-7-17
 *      Author: gexiao
 */
/*
 * Exception handling
 */
#ifndef EXCEPTION_H_
#define EXCEPTION_H_
#include "Inlines.h"

/*
 * Throw an exception in the current thread, by class descriptor.
 */
void dvmThrowChainedException(const char* exceptionDescriptor, const char* msg,
		Object* cause);

INLINE void dvmThrowException(const char* exceptionDescriptor, const char* msg) {
	dvmThrowChainedException(exceptionDescriptor, msg, NULL);
}

/*
 * Throw the named exception using the name of a class as the exception
 * message.
 */
void dvmThrowChainedExceptionWithClassMessage(const char* exceptionDescriptor,
		const char* messageDescriptor, Object* cause);
INLINE void dvmThrowExceptionWithClassMessage(const char* exceptionDescriptor,
		const char* messageDescriptor) {
	dvmThrowChainedExceptionWithClassMessage(exceptionDescriptor,
			messageDescriptor, NULL);
}

/*
 *
 */
void dvmThrowExceptionByClassWithClassMessage(ClassObject* exceptionClass,
		const char* messageDescriptor);

/*
 *
 */INLINE Object* dvmGetException(Thread* self) {

}

/*
 *
 */INLINE void dvmSetException(Thread* self, Object* exception) {

}

/*
 *
 */INLINE void dvmClearException(Thread* self) {

}

/*
 * Returns "true" if an exception is pending. Use this if you have a
 * "self" pointer.
 */INLINE bool dvmCheckException(Thread* self) {
	return (self->exception != NULL);
}

/*
 * Wrap the now-pending exception in a different exception.
 *
 * If something fails, an (unchecked) exception related to that failure
 * will be pending instead.
 */
void dvmWrapException(const char* newExcepStr);

/*
 * Print the exception stack trace to the log file.  The exception stack
 * trace is computed within the VM.
 */
void dvmLogExceptionStackTrace(void);

/*
 *
 */
int dvmFindCatchBlock(Thread* self, int relPc, Object* exception,
		bool doUnroll, void** newFrame);
#endif /* EXCEPTION_H_ */
